<?php
/**
 * 淘宝物流API
 *
 * Class LogisticsAPI
 */
class LogisticsAPI {
    /**
     * @var null 淘宝客户端
     */
    private $_client;

    /**
     * @param $options
     *
     * @throws APIException
     */
    public function __construct($options) {
        $client=isset($options[0])?$options[0]:null;
        if(!$client||!$client instanceof TaobaoClient){
            throw new APIException(10001,'淘宝API 客户端载入失败');
        }
        $this->_client=$client;
    }

    /**
     * 更新 线下发货
     *
     * @param $tid
     * @param $out_sid
     * @param $company_code
     *
     * @return mixed
     */
    public function offlineSend($tid, $out_sid,$company_code='花集物流'){
        return $this->_client->api('taobao.logistics.offline.send',  array(
            'tid' => $tid,
            'out_sid' => $out_sid,
            'company_code' => $company_code
        ));
    }

    /**
     * 无需物流发货(虚拟发货)
     * @param $tid
     *
     * @return mixed
     * @throws APIException
     */
    public function dummySend($tid){
        return $this->_client->api('taobao.logistics.dummy.send',  array(
            'tid' => $tid
        ));
    }
}